package com.da.springcloud.controller;

import javax.annotation.Resource;

import com.da.springcloud.entities.CommonResult;
import com.da.springcloud.service.StorageService;
import com.da.springcloud.util.ResultUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author JokerDa.
 * @date 2021/1/18 16:00
 * Description:
 */
@RestController
public class StorageController {

    @Resource
    private StorageService storageService;

    /**
     * 减库存
     *
     * @param productId
     * @param count
     * @return
     */
    @PostMapping(value = "storage/decrease")
    public CommonResult<Void> decrease(@RequestParam("productId") Long productId,
                                       @RequestParam("count") Integer count) {
        storageService.decrease(productId, count);
        return ResultUtil.success("扣减库存成功");
    }
}
